from django.db import models

# Create your models here.

# 用户表
from xiaoshuo.utils.models import BaseModel


class User(models.Model):
    USER_METHODS_ENUM={
        'UNPAID':0,
        'UNSEND':1
    }
    USER_METHOD_CHOICES=(
        (0,'普通用户'),
        (1,'会员用户')
    )
    username=models.CharField(verbose_name='用户名',max_length=20,unique=True)
    password=models.CharField(verbose_name='密码',max_length=100)
    mobile=models.CharField(verbose_name='手机号',max_length=11,unique=True)
    photo = models.CharField(max_length=256,verbose_name='头像')
    tatuls=models.SmallIntegerField(choices=USER_METHOD_CHOICES,default=0,verbose_name='用户状态')
    class Meta:
        db_table='tb_users'
        verbose_name_plural='用户表'
    def __str__(self):
        return self.username

# Vip表
class Vip(models.Model):
    vip_month = models.CharField(verbose_name='会员',max_length=11)
    price = models.CharField(max_length=10,verbose_name='价格')
    class Meta:
        db_table = 'tb_vip'
        verbose_name_plural = 'vip表'

class UserVip(BaseModel):
    user = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='用户')
    vip = models.ForeignKey(Vip,on_delete=models.CASCADE,verbose_name='VIP')
    class Meta:
        db_table = 'tb_user_vip'
        verbose_name = '中间表'
        verbose_name_plural = verbose_name
